unit NewSOrderList;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, BaseBillList, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxContainer, cxEdit, dxSkinsCore,
  dxSkinsDefaultPainters, cxStyles, dxSkinscxPCPainter,
  cxDataStorage, DB, cxDBData, Menus, DBActns,
  StdActns, ActnList, ImgList, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid,
  cxLabel, ExtCtrls, GlobalVar, MisString, cxGridCustomPopupMenu,
  dxSkinsForm, cxNavigator, Vcl.ComCtrls, dxCore, cxDateUtils, cxCustomData,
  cxFilter, cxData, cxGridPopupMenu, MemDS, DBAccess, Uni, System.Actions,
  System.ImageList, cxGridLevel, cxTextEdit, cxMaskEdit, cxDropDownEdit,
  cxCalendar, Vcl.StdCtrls, cxButtons, cxCheckBox;

type
  TfrmNewSOrderList = class(TfrmBaseBillList)
    procedure FormCreate(Sender: TObject);
    procedure PopmnuNewRecordClick(Sender: TObject);
    procedure MainDataGridDBTableViewDblClick(Sender: TObject);
    procedure PopmnuModifyRecordClickClick(Sender: TObject);
  private
    { Private declarations }
  protected
    function GetOpenWhereSQL: string; override;
  public
    { Public declarations }
  end;

var
  frmNewSOrderList: TfrmNewSOrderList;

implementation

uses ClientCenter;

{$R *.dfm}

{ TfrmNewSOrderList }

function TfrmNewSOrderList.GetOpenWhereSQL: string;
begin
  Result := inherited GetOpenWhereSQL;
  Result := Result + ' and m.bstate=0';
end;

procedure TfrmNewSOrderList.FormCreate(Sender: TObject);
begin
  FBType := btSaleOrder;
  inherited;  
end;

procedure TfrmNewSOrderList.PopmnuNewRecordClick(Sender: TObject);
begin
  inherited;
  ExecFunction(2, btSaleOrder);
end;

procedure TfrmNewSOrderList.MainDataGridDBTableViewDblClick(
  Sender: TObject);
begin
  if MainDataSource.DataSet.IsEmpty then Exit;
  if frmClientCenter = nil then
    frmClientCenter := TfrmClientCenter.Create(nil);
  frmClientCenter.LoadNewSOrder(MainDataSource.DataSet.FieldByName('BID').AsInteger);
  frmClientCenter.Show;
//  inherited;
end;

procedure TfrmNewSOrderList.PopmnuModifyRecordClickClick(Sender: TObject);
begin
  inherited;
  if MainDataSource.DataSet.IsEmpty then Exit;
  if frmClientCenter = nil then
    frmClientCenter := TfrmClientCenter.Create(nil);
  frmClientCenter.LoadNewSOrder(MainDataSource.DataSet.FieldByName('BID').AsInteger);
  frmClientCenter.Show;
end;

end.

